﻿Imports System.Data
Imports System.Data.OleDb

Partial Class Articles_AddArticles
    Inherits System.Web.UI.Page

    Protected Sub btnSubmit_Click(sender As Object, e As System.EventArgs) Handles btnSubmit.Click
        Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("myFirstDatabase").ConnectionString)
        Dim SqlString As String = "Insert into tblArticles(firstname,lastname,Content,DateSubmitted,Topic) Values (@f1,@f2,@f3,@f4,@f5)"
        Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
        Dim SubmittedDate As DateTime = Now()
        Dim format As String = "ddd MMM yyyy"
        cmd.CommandType = CommandType.Text
        cmd.Parameters.AddWithValue("@f1", txtfirstname.Text)
        cmd.Parameters.AddWithValue("@f2", txtlastname.Text)
        cmd.Parameters.AddWithValue("@f3", txtcontent.Text)
        cmd.Parameters.AddWithValue("@f4", SubmittedDate.ToString(format))
        cmd.Parameters.AddWithValue("@f5", ddl_Articles.SelectedValue)
        oleDbConn.Open()
        cmd.ExecuteNonQuery()
        Response.Redirect("Confirmation.aspx")
    End Sub
End Class
